package com.example.demo.service;

import java.util.List;
import java.util.UUID;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.example.demo.bean.CmsMember;
import com.example.demo.mapper.CmsMemberMapper;

@Service
public class CmsMemberService {
	@Autowired
	private CmsMemberMapper memberMapper;
	
	
	
	
	
	
	public List<CmsMember> getAllMember() {
		List<CmsMember> list=memberMapper.selectAll();
		return list;
	}



	public boolean saveOrUpdateCmsMember(CmsMember member) {
		if(member.getId()!=null) {
			memberMapper.updateByPrimaryKey(member);
			
		}
		else {
			member.setId(UUID.randomUUID().toString());
			memberMapper.insert(member);
			
		}
			return true;	
	}



	public int deleteById(String id) {
		return memberMapper.deleteByPrimaryKey(id);
	}



	public boolean updateState(String memId, int state) {
		int result = memberMapper.updateStateById(memId, state);
		//返回结果代表更新的记录条数，如果一条都没有，代表数据不存在。
		if(result==0) { 
			return false;
		}
		return true;
	}



	



	

}
